﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kokomo
{
	public class UiString : IComparable
	{
		public string Value { get; private set; }

		public static UiString FromString(string str)
		{
			if (str == null) return null;
			else return new UiString(str);
		}

		private UiString(string value)
		{
			this.Value = value;
		}

		public static implicit operator string(UiString uistr)
		{
			if (uistr == null) return null;
			return uistr.Value;
		}

		public override string ToString()
		{
			return this.Value;
		}

		public override bool Equals(object obj)
		{
			UiString uistr = obj as UiString;
			if (uistr != null) return this.Value == uistr.Value;

			string str = obj as string;
			if (str == null) return this.Value == str;

			return base.Equals(obj);
		}
		public override int GetHashCode()
		{
			return this.Value.GetHashCode();
		}

		public int CompareTo(object obj)
		{
			return this.Value.CompareTo((obj == null) ? null : obj.ToString());
		}
	}
}
